<?php

class AjaxController extends Controller
{
	public function init()
	{
		$this->layout = false;
	}

	public function render($var)
	{
		header('Content-type: application/json');
		echo  CJSON::encode($var);
		Yii::app()->end(); 
	}

	public function actionGetcity()
	{
		$nid = Yii::app()->request->getParam('nid');
		$thanhpho = Thanhpho::model()->findAll("id_quocgia = :nid",array("nid" => $nid));

		$this->render($thanhpho);
	}

	public function actionGetuser()
	{
		$username = Yii::app()->request->getParam('username');
		$user = Nhatuyendung::model()->findAll("tendangnhap = :username",array("username" => $username));
		if(!empty($user)) $var = array('result' => false);
		else $var = array('result' => true);
		$this->render($var);
	}
}